import request from "@/api";
import { BaseRet, ListRet, ObjectRet } from "@/api/response";
import { ChatUserModel } from "./model";

class ChatUserApi {
  /**
   * 查询聊天好友
   * @returns
   */
  static async query(): Promise<ListRet<ChatUserModel>> {
    return await request({
      url: `ChatUser/GetChatUserList`,
      method: "get",
    });
  }

  /**
   * 根据好友主键查询聊天好友
   * @returns
   */
  static async queryChatUser(friendId: string): Promise<ObjectRet<ChatUserModel>> {
    return await request({
      url: `ChatUser/GetChatUser/${friendId}`,
      method: "get",
    });
  }

  /**
   * 不显示聊天记录
   * @param id 聊天好友主键
   * @returns
   */
  static async hide(id: string): Promise<BaseRet> {
    return await request({
      url: `ChatUser/hide/${id}`,
      method: "get",
    });
  }

  /**
   * 删除聊天记录
   * @param id 聊天好友主键
   * @returns
   */
  static async delete(id: string): Promise<BaseRet> {
    return await request({
      url: `ChatUser/delete/${id}`,
      method: "delete",
    });
  }

  /**
   * 好友列表点击发送消息，如果是隐藏状态，则改为显示
   * @returns
   */
  static async create(friendId: string): Promise<ObjectRet<ChatUserModel>> {
    return await request({
      url: `ChatUser/Create/${friendId}`,
      method: "get",
    });
  }
}

export default ChatUserApi;
